<html>
<head>
    <meta charset="utf-8">
    <title>IFE JavaScript Task 01</title>
</head>
<body>

<h3>污染城市列表</h3>
<ul id="aqi-list">
    <!--
        <li>第一名：福州（样例），10</li>
          <li>第二名：福州（样例），10</li> -->
</ul>

<script type="text/javascript">

    var aqiData = [
        ["北京", 90],
        ["上海", 50],
        ["福州", 10],
        ["广州", 50],
        ["成都", 90],
        ["西安", 100]
    ];

    (function () {

        /*
         在注释下方编写代码
         遍历读取aqiData中各个城市的数据
         将空气质量指数大于60的城市显示到aqi-list的列表中
         */
        function ascend(x, y){
            return y[1] - x[1]  ;
        };
        var newarr = aqiData.sort(ascend);
        var newarr2 = ["一","二","三","四","五","六"];
        for(var i = 0;i < newarr.length;i++){
            var aqiList = document.getElementById('aqi-list');
            if(newarr[i][1] > 60){
                var node = document.createElement("li");
                var textnode = document.createTextNode('第'+newarr2[i]+'名:'+ newarr[i][0]+","+newarr[i][1]);
                node.appendChild(textnode);
                aqiList.appendChild(node);
            }
        }
    })();

</script>
</body>
</html>